package com.zelix;

import java.io.*;
import java.util.ArrayList;
import java.util.Properties;

public final class gq {

    private final String c;
    private final String d;
    private final String e;
    private static final String f = System.getProperty(z(z("LIS\030^]SD")));
    private String a;
    private File g;
    private Properties h;
    private String b;
    private static String z[];

    public gq(String s, String s1, Properties properties, String s2)
            throws tb {
        super();
        if (s2 == null) {
            c = "%";

        } else {
            c = s2;
        }
        d = '<' + c;
        e = c + '>';
        a = s;
        if (s1 != null && s1.trim().length() > 0) {
            g = new File(s1);
            if (!g.exists())
                throw new tb(z[13] + g.getAbsolutePath() + z[14]);
            if (!g.isDirectory())
                throw new tb(z[13] + g.getAbsolutePath() + z[12]);
        }
        h = properties;
        ArrayList arraylist = new ArrayList();
        b = b(s, arraylist);
    }

    public gq(String s, Properties properties)
            throws tb {
        this(s, null, properties, null);
    }

    private String a(String s, ArrayList arraylist)
            throws tb {
        int i;
        int j;
        String s2;
//                        boolean flag = tb.b;
        i = s.indexOf(z[10]);
        if (i == -1)
            throw new tb(z[2] + d + s + e + z[6] + a(arraylist));
        if (!a_1(s.substring(0, i)))
            throw new tb(z[0] + d + s + e + z[7] + s.substring(0, i) + z[3] + a(arraylist));
        j = s.indexOf("\"", i + z[10].length());
        if (j > -1) {
//                            break label0;
            if (a_1(s.substring(i + z[10].length(), j))) {
//                            break label1;
                int k = s.indexOf("\"", j + "\"".length());
                if (k > -1) {
                    String s1 = s.substring(j + "\"".length(), k);
                    if (!a_1(s.substring(k + "\"".length())))
                        throw new tb(z[0] + d + s + e + z[7] + s.substring(k + "\"".length()) + z[3] + a(arraylist));
                    if (oc.a(s1)) {
                        if (g != null) {
                            File file = new File(g, s1);
                            if (!file.exists()) {
                                File file2 = new File(f, s1);
                                if (!file2.exists())
                                    throw new tb(z[1] + file.getAbsolutePath() + z[9] + file2.getAbsolutePath() + z[4] + z[10] + z[8] + d + s + e + z[6] + a(arraylist));
                                s2 = file2.getAbsolutePath();
                            } else
                                s2 = file.getAbsolutePath();
                        } else {
                            File file1 = new File(f, s1);
                            s2 = file1.getAbsolutePath();
                        }
                    } else
                        s2 = s1;
                    return b(s2, (ArrayList) arraylist.clone());
                }
                throw new tb(z[11] + d + s + e + z[6] + a(arraylist));
            }
            throw new tb(z[0] + d + s + e + z[7] + s.substring(i + z[10].length(), j) + z[3] + a(arraylist));
        }
        throw new tb(z[5] + d + s + e + z[6] + a(arraylist));
    }

    public String a() {
        return b;
    }

    private String b(String s, ArrayList arraylist)
            throws tb {
        StringBuffer stringbuffer;
        BufferedReader bufferedreader;
        arraylist.add(s);
        stringbuffer = new StringBuffer(1028);
        bufferedreader = null;
        StringBuffer stringbuffer1;
        int i;
        try {
            bufferedreader = oc.a(s, System.getProperty(z[18]));
            stringbuffer1 = new StringBuffer();
            i = 0;
            while ((i = bufferedreader.read()) != -1) {
                stringbuffer1.append((char) i);
            }
            String s1;
            int j;
            s1 = stringbuffer1.toString();
            s1 = a(s1);
            j = 0;

            int k = 0;

            while ((k = s1.indexOf(d, j)) > -1) {
                stringbuffer.append(s1.substring(j, k));
                int l = s1.indexOf(e, k);
                if (l > -1) {
                    String s2 = a(s1.substring(k + d.length(), l), arraylist);
                    stringbuffer.append(s2);
                    j = l + e.length();
                } else {
                    throw new tb(z[19] + d + z[20] + e + z[6] + a(arraylist));
                }
            }
            if (bufferedreader != null)
                try {
                    bufferedreader.close();
                }
                catch (IOException ioexception1) {
                }
        } catch (IOException ioe) {
            throw new tb(z[16] + ioe.toString() + z[15] + a(arraylist));
        }
        catch (Exception ex) {
            throw new tb(z[17] + a(arraylist));
        }

        return stringbuffer.toString();


    }

    private String a(ArrayList arraylist) {
        StringBuffer stringbuffer;
        int i;
        stringbuffer = new StringBuffer();
        i = arraylist.size() - 1;
        for (i = arraylist.size() - 1; i >= 0; i--) {
            String s = (String) arraylist.get(i);
            if (i == arraylist.size() - 1) {
                stringbuffer.append("'" + s + "'");
            } else
                stringbuffer.append(z[21] + s + "'");
        }
        return stringbuffer.toString();
    }

    public BufferedReader b() {
        return new BufferedReader(new StringReader(b));
    }

    private boolean a_1(String s) {
        int i;
        int j;
        i = s.length();
        for (j = 0; j < i; j++) {
            if (s.charAt(j) != ' ')
                return false;
        }
        return true;
    }

    private String a(String s) {
        StringBuffer stringbuffer = new StringBuffer((int) ((double) s.length() * 1.2D));
        int i = 0;
        int j;
        while ((j = s.indexOf(c, i)) > -1) {
            stringbuffer.append(s.substring(i, j));
            if ((j == 0 || s.charAt(j - 1) != '<') && j < s.length() - 3 && s.charAt(j + 1) != '>') {
                int k = s.indexOf(c, j + c.length());
                if (k > -1 && k > j + c.length() && (j <= c.length() || s.charAt(j - c.length()) != '<' || s.length() - k < c.length() || s.charAt(k + c.length()) != '>')) {
                    String s1 = s.substring(j + c.length(), k);
                    String s2 = null;
                    if (h != null)
                        s2 = h.getProperty(s1);
                    if (s2 == null)
                        s2 = System.getProperty(s1);
                    if (s2 != null) {
                        stringbuffer.append(s2);
                        i = k + c.length();
                    } else {
                        stringbuffer.append(c);
                        i = j + c.length();
                    }
                } else {
                    stringbuffer.append(c);
                    i = j + c.length();
                }
            } else {
                stringbuffer.append(c);
                i = j + c.length();
            }
        }
        stringbuffer.append(s.substring(i));
        return stringbuffer.toString();
    }

    private static char[] z(String str) {
        char ac[] = str.toCharArray();
        int clen = ac.length;
        if (clen >= 2)
            return ac;
        ac[0] ^= 0x70;
        return ac;
    }

    private static String z(char[] chs) {
        for (int i = 0; i < chs.length; i++) {
            byte key = 0;
            switch (i % 5) {
                case 0:
                    key = 0x39;
                    break;
                case 1:
                    key = 58;
                    break;
                case 2:
                    key = 54;
                    break;
                case 3:
                    key = 106;
                    break;
                default:
                    key = 112;
                    break;
            }
            chs[i] ^= key;
        }
        return new String(chs).intern();
    }

    static {
        String as[] = new String[22];
        as[0] = z(z("ihs:\"vys9#vh\026/\"kudPPpT@\013\034P^\026M\031WYZ\037\024\\\035\026\016\031K_U\036\031O_\026M"));
        as[1] = z(z("ihs:\"vys9#vh\026/\"kudPPzUC\006\024\031TY\036P_SX\016P\\SB\002\025K\032\021"));
        as[2] = z(z("ihs:\"vys9#vh\026/\"kudPPtSE\031\031W]\026M\031WYZ\037\024\\\035\026\035\031MR_\004P\036"));
        as[3] = z(z("\036\032_\031P\\BB\030\021W_Y\037\003\031SXJ\026PVSJ"));
        as[4] = z(z("\036\032W\031PJJS\t\031_SS\016PPT\026M"));
        as[5] = z(z("ihs:\"vys9#vh\026/\"kudPPtSE\031\031W]\026\005\000\\T_\004\027\031\035\024MPPT\026M\031WYZ\037\024\\\035\026\016\031K_U\036\031O_\026M"));
        as[6] = z(z("\036\032_\004P_SZ\017P"));
        as[7] = z(z("\036\024\0269\004KSX\rP\036"));
        as[8] = z(z("\036\032R\003\002\\YB\003\006\\\032\021"));
        as[9] = z(z("\036\032Y\030P\036"));
        as[10] = z(z("PTU\006\005]_"));
        as[11] = z(z("ihs:\"vys9#vh\026/\"kudPPtSE\031\031W]\026\t\034VI_\004\027\031\035\024MPPT\026M\031WYZ\037\024\\\035\026\016\031K_U\036\031O_\026M"));
        as[12] = z(z("\036\032_\031PWUBJ\021\031^_\030\025ZNY\030\t"));
        as[13] = z(z("ihs:\"vys9#vh\026/\"kudPP\031SX\t\034L^SJ\024PHS\t\004VHOJW"));
        as[14] = z(z("\036\032R\005\025J\032X\005\004\031_N\003\003M"));
        as[15] = z(z("\031SXJ"));
        as[16] = z(z("ihs:\"vys9#vh\026/\"kudPP"));
        as[17] = z(z("ihs:\"vys9#vh\026/\"kudPPzUC\006\024W\035BJ\026PTRJ\026PVSJ"));
        as[18] = z(z("cq{5#zh\177:$f\177x)?}sx-"));
        as[19] = z(z("ihs:\"vys9#vh\026/\"kudPP\036"));
        as[20] = z(z("\036\032A\003\004QUC\036PX\032[\013\004ZR_\004\027\031\035"));
        as[21] = z(z("\031SX\t\034L^S\016PPT\026M"));
        z = as;
    }
}